<script>
  $(document).ready(function(){
    var str = $("#Users_expired_date").val();
    var arr = str.split("-");
    
    $("#plus").click(function(){
      var year = parseInt(arr[0])+1;
      $("#Users_expired_date").val(year+"-"+arr[1]+"-"+arr[2]);
      
      str = $("#Users_expired_date").val();
      arr = str.split("-");
    });
    
    $("#minus").click(function(){
      var year = parseInt(arr[0])-1;
      $("#Users_expired_date").val(year+"-"+arr[1]+"-"+arr[2]);
      
      str = $("#Users_expired_date").val();
      arr = str.split("-");
    });
  });
</script>

<div class="main-content">
    <header>
        <h2>School Member</h2>
    </header>

    <section>
        <?php echo $this->renderPartial('/partials/_notifications'); ?>
        <?php
          $form = $this->beginWidget('CActiveForm', array(
            'id' => 'form',
            'action' => bu('admin/schools/update'),
            'htmlOptions' => array(
              'novalidate' => 'true',
              'enctype' => 'multipart/form-data',
            ),
          ));
        ?>
        <?php echo $form->errorSummary($data); ?><br />

        <?php echo $form->hiddenField($data, 'user_id'); ?>

        
        
        <label>HQ #</label>
        <?php echo $form->textField($data, 'hq') ?> &nbsp;
        <button class="button button-gray" type="submit"><span class="accept"></span>Update Information</button>

        <?php if($user->status == Users::STATUS_APPROVED){ ?>
          <a href="<?php echo bu("admin/users/decline?id=".$user->id); ?>" class="button button-gray" title="Decline this membership">Decline<span class="accept"></span></a>
        <?php }else{ ?>
          <a href="<?php echo bu("admin/users/approve?id=".$user->id); ?>" class="button button-gray" title="Approve this membership">Approve<span class="accept"></span></a>
        <?php } ?>
        
        <?php if($user->payment_confirm == Users::STATUS_NOT_PAID){ ?>
          <a href="<?php echo bu("admin/users/paymentconfirm?id=".$user->id); ?>" class="button button-gray" title="Confirm this user payment">Confirm Payment<span class="accept"></span></a>
        <?php }else{ ?>
          <a href="<?php echo bu("admin/users/paymentdecline?id=".$user->id); ?>" class="button button-gray" title="Click here if user not paid yet">Not Paid yet<span class="accept"></span></a>
        <?php } ?>
        
        <br /><br />
        
        <fieldset>
          <legend>Membership Expired Date</legend>
          <?php if($user->payment_confirm == Users::STATUS_PAID){ ?>
            <?php echo $form->textField($user, 'expired_date') ?>
            <button class="has-popupballoon button button-gray" id="plus">+</button>
            <button class="has-popupballoon button button-gray" id="minus">-</button>
          <?php }else{ ?>
            <p><i>This user payment hasn't been confirmed yet</i></p>
          <?php } ?>
        </fieldset>
        <?php $this->endWidget(); ?>

				<fieldset>
					<legend>Contact Information</legend>

          <table class="custom full">
            <tr>
              <th><label>School Name</label></th>
              <td><?php echo $user->school_name; ?></td>
            </tr>
            <tr>
              <th><label>Email</label></th>
              <td><?php echo $user->email; ?></td>
            </tr>
            <tr>
              <th><label>Address</label></th>
              <td><?php echo $user->address; ?></td>
            </tr>
            <tr>
              <th><label>Phone</label></th>
              <td><?php echo $data->phone; ?></td>
            </tr>
            <tr>
              <th><label>Fax</label></th>
              <td><?php echo $data->fax; ?></td>
            </tr>
            <tr>
              <th><label>Website</label></th>
              <td><a href="http://<?php echo $data->website; ?>"><?php echo $data->website; ?></a></td>
            </tr>
            <tr>
              <th><label>Founding Year</label></th>
              <td><?php echo $data->founded; ?></td>
            </tr>
            <tr>
              <th><label>Member Since</label></th>
              <td><?php echo $data->member_since; ?></td>
            </tr>
            <tr>
              <th><label>School Director</label></th>
              <td><?php echo $data->school_director; ?></td>
            </tr>
            <tr>
              <th><label>List our email address in the directory?</label></th>
              <td>
                <?php if($data->list_email == 0){ ?>
                  <img src="<?php echo bu("images/icons/cross.png") ?>" />
                <?php }else{ ?>
                  <img src="<?php echo bu("images/icons/accept.png") ?>" />
                <?php } ?>
              </td>
            </tr>
            <tr>
              <th><label>Post our school on the ACSI website?</label></th>
              <td>
                <?php if($data->post_school == 0){ ?>
                  <img src="<?php echo bu("images/icons/cross.png") ?>" />
                <?php }else{ ?>
                  <img src="<?php echo bu("images/icons/accept.png") ?>" />
                <?php } ?>
              </td>
            </tr>
          </table>
        </fieldset>

        <fieldset>
        <legend>Additional Information</legend>

        <table class="custom full">
          <tr><th>School Program</th></tr>
          <tr>
            <td>Accredited By</td>
            <td><?php echo $data->accredited_by; ?></td>
          </tr>
          <tr><th>Form Legal Entity</th></tr>
          <tr>
            <td>Name</td>
            <td><?php echo $data->organization_name; ?></td>
          </tr>
          <tr>
            <td>Address</td>
            <td><?php echo $data->organization_address; ?></td>
          </tr>
          <tr>
            <td>Phone</td>
            <td><?php echo $data->organization_phone; ?></td>
          </tr>
          <tr>
            <td>Fax</td>
            <td><?php echo $data->organization_fax; ?></td>
          </tr>
          <tr>
            <td>Email</td>
            <td><?php echo $data->organization_email; ?></td>
          </tr>
          <tr><th>Supporting Church</th></tr>
          <tr>
            <td>Name</td>
            <td><?php echo $data->church_name; ?></td>
          </tr>
          <tr>
            <td>Address</td>
            <td><?php echo $data->church_address; ?></td>
          </tr>
          <tr>
            <td>Phone</td>
            <td><?php echo $data->church_phone; ?></td>
          </tr>
          <tr>
            <td>Fax</td>
            <td><?php echo $data->church_fax; ?></td>
          </tr>
          <tr>
            <td>Email</td>
            <td><?php echo $data->church_email; ?></td>
          </tr>
          <tr><th>Supporting Individual (Owner)</th></tr>
          <tr>
            <td>Name</td>
            <td><?php echo $data->owner_name; ?></td>
          </tr>
          <tr>
            <td>Address</td>
            <td><?php echo $data->owner_address; ?></td>
          </tr>
          <tr>
            <td>Phone</td>
            <td><?php echo $data->owner_phone; ?></td>
          </tr>
          <tr>
            <td>Fax</td>
            <td><?php echo $data->owner_fax; ?></td>
          </tr>
          <tr>
            <td>Email</td>
            <td><?php echo $data->owner_email; ?></td>
          </tr>
        </table>
      </fieldset>

      <fieldset>
        <legend>Membership Fee</legend>

        <table class="custom full">
          <tr>
            <th>Membership Type</th>
            <td><?php echo $data->membership_status; ?></td>
          </tr>
          <tr>
            <th>Membership Fee</th>
            <td><?php echo $user->membership_fee; ?></td>
          </tr>
        </table>
      </fieldset>

      <?php if(isset($user->gift_type)){ ?>
      <fieldset>
        <legend>Ministries Gift</legend>

        <table class="custom full">
          <tr>
            <th>Gift Type</th>
            <td><?php echo $user->gift_type; ?></td>
          </tr>
          <tr>
            <th>Gift Value</th>
            <td><?php echo $user->gift_value; ?></td>
          </tr>
        </table>
      </fieldset>
      <?php } ?>

      <fieldset>
        <legend>Others</legend>

        <table>
          <tr>
            <th>Schedule ACSI Indonesia visit to your school</th>
            <td><?php echo $data->date_visited; ?></td>
          </tr>
          <tr>
            <th>Needs #1</th>
            <td><?php echo $data->needs1; ?></td>
          </tr>
          <tr>
            <th>Needs #2</th>
            <td><?php echo $data->needs2; ?></td>
          </tr>
          <tr>
            <th>Needs #3</th>
            <td><?php echo $data->needs3; ?></td>
          </tr>
          <tr>
            <th>Pray #1</th>
            <td><?php echo $data->pray1; ?></td>
          </tr>
          <tr>
            <th>Pray #2</th>
            <td><?php echo $data->pray2; ?></td>
          </tr>
          <tr>
            <th>Pray #3</th>
            <td><?php echo $data->pray3; ?></td>
          </tr>
        </table>
      </fieldset>

      <?php foreach($schools as $school){ ?>
      <fieldset>
        <legend><?php echo $school->school_type; ?></legend>

        <table class="custom full">
          <tr>
            <th>Number of students for all unit schools</th>
            <td><?php echo $school->enrollment; ?></td>
          </tr>
          <tr>
            <th>Principal Name, Title</th>
            <td><?php echo $school->principal_name_title; ?></td>
          </tr>
          <tr>
            <th>Principal Email</th>
            <td><?php echo $school->principal_email; ?></td>
          </tr>
          <tr><th>Number of Teachers</th></tr>
          <tr>
            <td>Full-time</td>
            <td><?php echo $school->full_time_teachers; ?></td>
          </tr>
          <tr>
            <td>Part-time</td>
            <td><?php echo $school->part_time_teachers; ?></td>
          </tr>
          <tr>
            <td>Goverment Assigned</td>
            <td><?php echo $school->goverment_teachers; ?></td>
          </tr>
          <tr><th>Teacher's Education</th></tr>
          <tr>
            <td>Diploma</td>
            <td><?php echo $school->diploma_teachers; ?></td>
          </tr>
          <tr>
            <td>S1 (Bachelor)</td>
            <td><?php echo $school->s1_teachers; ?></td>
          </tr>
          <tr>
            <td>S2 (Master)</td>
            <td><?php echo $school->s2_teachers; ?></td>
          </tr>
          <tr>
            <td>S3 (Doctor)</td>
            <td><?php echo $school->s3_teachers; ?></td>
          </tr>
          <tr>
            <th>Status</th>
            <td><?php echo $school->status; ?></td>
          </tr>
          <tr>
            <th>Membership Sought</th>
            <td><?php echo $school->membership_sought; ?></td>
          </tr>
        </table>
      </fieldset>
      <?php } ?>
    </section>

</div>